﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Microsoft.Samples.ServiceHosting.StorageClient;

namespace Astoman.Common.Repository
{
    public class TableRepository : IBaseRepository
    {
        private TableStorage _ts = null;

        public TableRepository(StorageAccountInfo accountInfo)
        {
            _ts = TableStorage.Create(accountInfo);
        }
        
        public List<String> List()
        {
            var tables = _ts.ListTables();
            return tables.ToList();
        }

        public bool Delete(String tableName)
        {
            var worked = _ts.TryDeleteTable(tableName);
            return worked;
        }

        public int Count()
        {
            return _ts.ListTables().Count();
        }
    }
}
